import { axios } from '@/utils/request'

export function getSysRoleList(params) {
  return axios({
    url: '/sys/role/pageListRoles',
    method: 'post',
    data: params
  })
}
//新增角色
export function addSysRole (parameter) {
  return axios({
    url: '/sys/role/addRole',
    method: 'post',
    data: parameter
  })
}
export function editSysRole (parameter) {
  return axios({
    url: '/sys/role/updateRole',
    method: 'post',
    data: parameter
  })
}
//根据roleId查询关联的菜单信息
export function getSysDelRole(parameter) {
  return axios({
    url: `/sys/role/delete`,
    method: 'post',
    data:parameter
  })
}
//新增角色分配菜单
export function sysRoleDistributeMenu (parameter) {
  return axios({
    url: '/sys/role/applyMenuToRole',
    method: 'post',
    data: parameter
  })
}
 //根据roleId查询关联的菜单信息
export function getSysRoleIdTree(roleId) {
     roleId = roleId !== undefined ? roleId : '';
  return axios({
    url: `/sys/role/listRoleMenuIds?roleId=${roleId}`,
    method: 'get'
  })
}
//该角色类型编码下的所有角色,创建企业或者园区的时候使用
export function getSysUserTypeCodeAllRole(roleTypeCode) {
     roleTypeCode = roleTypeCode !== undefined ? roleTypeCode : '';
  return axios({
    url: `/sys/role/listRolesByRoleTypeCode?roleTypeCode=${roleTypeCode}`,
    method: 'get'
  })
}
export function setRoleDataPermission(data) {
  return axios({
    url: '/sys/hr/role/add',
    method: 'post',
    data
  })
}
export function getRoleDataPermission(roleId) {
  return axios({
    url: '/sys/hr/role/getByRoleId?roleId='+roleId,
    method: 'get'
  })
}